<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc_min.jsp"></jsp:include>
<title>平台订单体现</title>
<link rel="stylesheet" href="${ctx}/css/page.css"/>
<link rel="stylesheet" href="${ctx}/css/iconfont.css"/>
<script type="text/javascript">
	$(function(){
		
		$("#all").click(function(){    
		    if(this.checked){    
		        $(".checkList :checkbox").attr("checked", true);   
		    }else{    
		        $(".checkList :checkbox").attr("checked", false); 
		    }    
		});  
		//设置全选复选框 
		$("table").delegate(".aa","click",function(){
			allchk();
		})
		//点击全选后  如果取消了其中的选中  则全选按钮取消选中
		function allchk(){ 
		    var chknum = $(".checkList :checkbox").size();//选项总个数 
		    var chk = 0; 
		    $(".checkList :checkbox").each(function () {   
		        if($(this).attr("checked")==true){ 
		            chk++; 
		        } 
		    }); 
		    if(chknum==chk){//全选 
		        $("#all").attr("checked",true); 
		    }else{//不全选 
		        $("#all").attr("checked",false); 
		    } 
		};
		//提现
		$("#getValue").click(function(){ 
		    
		    reqSettlement();
		});
		//点击查询 重新加载列表
		$("#query").click(function(){
            pageNum = 1;
            getData();
		});
        getData();
	});
    var pageNum = 1;
    function getData() {
        //获取参数
        var orderNumber=$("#_orderNumber").val();
        var toStartAirportCode=$("#_startCity").val();
        var toEndAirportCode=$("#_endCity").val();
        var toStartDate=$("#startDate").val();
        var toEndDate=$("#endDate").val();
        if(typeof(toStartAirportCode) == 'undefined'){
            toStartAirportCode = "";
        }
        if(typeof(toEndAirportCode) == 'undefined'){
            toEndAirportCode = "";
        }
        var param = {
            "orderNumber":orderNumber,
            "toStartAirportCode":toStartAirportCode,
            "toEndAirportCode":toEndAirportCode,
            "toStartDate":toStartDate,
            "toEndDate":toEndDate,
            "page":pageNum,
            "rows":20
        }
        $.get('${ctx}/search/getPlatformList?financeStatus=3&temp='+Math.random(),param,function(data){
            $('table tbody').empty();
            var str = "";
            for(var i=0;i<data.rows.length;i++){
                var obj = data.rows[i];
                var id=obj.id;
                str+="<tr height='38px' class='reBorder'>"
                str+="	<td colspan='7'width='965' class='checkList'>"
                str+="		<span class='mLeft'><input class='aa' type='checkbox' name='checkInp' value='"+obj.orderNumber+"-"+obj.sum+"'/>&nbsp;平台："+obj.conNo+"</span>"
                str+="   		<span class='mLeft'>	供应商："+obj.pssConNo+"</span></td>"
                str+=	'<td align="right"><i class="icon iconfont position" title="详情" onclick=detail("'+obj.orderNumber+'")>&#xe62d;</i>';//詳情
                str+="	</td>"
                str+="</tr>"
                str+="<tr height='90px'>"
                str+="	<td width='139px' align='center'>"
                str+="		往：<span style='color:black;'>"+obj.list[0].airlineNumber+"</span><br/>"
                str+= (obj.list.length==2) ?  "返：<span style='color:black;'>"+obj.list[1].airlineNumber+"</span>" :  "";
                str+="	</td>"
                str+="	<td width='230px' align='right'>"
                str+="		<span>"+obj.list[0].deptTime+"</span><br/>"
                str+="		<span style='color:#444e50'>"+obj.list[0].deptCity+"</span><span style='color:#444e50'>("+obj.list[0].deptCode+")</span><span style='color:#e2615c'>"+obj.list[0].deptTerminal+"</span><br/>"
                str+= (obj.list.length==2) ?  "<span>"+obj.list[1].arrTime+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='157px' align='center'>"
                str+="		<span style='color:#23b9dc'>"+obj.list[0].deptDate+"</span><br/>"
                str+= (obj.list.length==2) ?  "<img src='${ctx}/image/flightQuery/round.gif'><br/>" :  "<img src='${ctx}/image/flightQuery/dancheng.png'><br/>";
                str+= (obj.list.length==2) ?  "<span style='color:#23b9dc'>"+obj.list[1].deptDate+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='202px'>"
                str+="		<span>"+obj.list[0].arrTime+"</span><span style='color:#e2615c;'>+"+obj.list[0].intervalDay+"</span><br/>"
                str+="		<span style='color:#444e50'>"+obj.list[0].arrCity+"</span><span style='color:#444e50'>("+obj.list[0].arrCode+")</span><span style='color:#e2615c'>"+obj.list[0].arrTerminal+"</span><br/>"
                str+= (obj.list.length==2) ?  "<span>"+obj.list[1].deptTime+"</span><br/>" :  "";
                str+="	</td>"
                str+="	<td width='145px' align='center' style='color:#444e50'>"+obj.buyerName+"</td>"
                str+="	<td width='68px' align='center' style='color:#444e50'>"+obj.purchQuantity+"</td>"
                str+="	<td width='120px' align='center' style='color:#e2615c'>"+obj.sum+"</td>"
                str+="	<td width='115px' align='center' style='color:#23b9dc'>"+CommonConverter.toOrderPayStatusStr(obj.financeStatus)+"</td>"
                //str+="	<td width='124px' align='center' style='color:#23b9dc'><span class='add_minus' style='margin-left:22px;'>提现</span></td>"
                str+="</tr>"
            }
            $('#tb').append(str);
            //显示分页
            layui.use(['laypage', 'layer'], function(){
                var laypage = layui.laypage;
                laypage({
                    cont: 'pager'
                    ,pages:  Math.ceil(data.total/20) //得到总页数 //总页数
                    ,groups: 5 //连续显示分页数
                    ,skin: '#1E9FFF'
                    ,curr : pageNum
                    ,jump: function(obj,first){
                        if(!first){
                            pageNum = obj.curr;
                            getData();
                        }
                    }
                });
            });
        })
    }
	//查看详情
	function detail(orderNumber){
		window.location.href='${ctx}/nporder/detail/'+orderNumber;
	};
	
	function reqSettlement(){
        var orderNos = new Array();
        var money = new Number;
	    $('input[name="checkInp"]:checked').each(function(i){
	        var chkval = $(this).val();
            var chkArr = chkval.split("-");
            orderNos.push(chkArr[0]);
            var sum = chkArr[1]-0;
            money += sum;
        });
		if(orderNos.length == 0){
			layer.alert("请先选择要提现的订单！");
			return false;
		}

		layer.confirm('您已选择'+orderNos.length+'个订单，总金额'+money+'元<br>确认申请提现吗？', {
			  btn: ['确定','取消'] //按钮
			}, function(){
				layer.load(0, {shade: false});
				$.ajax({
					type:'post',
					url:'${ctx}/withdrawal',
					contentType:'application/json;charset=utf-8',
					data:JSON.stringify(orderNos),
					dataType:'json',
					success:function(data){
						layer.closeAll('loading');
						layer.alert('提现申请已提交<br>提现单号：'+data,{skin:'layui-layer-lan',title: ['系统提示', 'background-color:#00B2EE; color:#fff;'],closeBtn: 0}, function(index){
							 getData();
							layer.close(index);
						});
					},
					error:function(msg){
						layer.alert("请检查您的网络连接，然后重试！");
						layer.closeAll('loading');
					}
				}); 
			}, function(){
				layer.closeAll('loading');
			});
	}
</script>
</head>
<body>
<jsp:include page="../head.jsp"/>
	<div class="content">
		<ul class="list">
				<li>订单号：<input  id="_orderNumber" name="charterType" class="easyui-textbox textbox" style="width: 120px;"/></li>
				<li>出发城市：
				<input type="text" value="" size="15" id="homecity_name" name="homecity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel" mod_address_suggest="" mod_address_reference="_startCity" mod_notice_tip="中文/拼音" />
					<input id="_startCity" name="_startCity" type="hidden" value="" />
				</li>
				<li>到达城市：
				<input type="text" value="" size="15" id="getcity_name" name="getcity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel"  mod_address_reference="_endCity" mod_notice_tip="中文/拼音" />
					<input id="_endCity" name="_endCity" type="hidden" value="" />
				</li>
				<li>
					出发时间 ：<input type="text" id="startDate" class="Wdate"  value="${requestScope.deptDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'/*,minDate:'%y-%M-\#{%d+2}',maxDate:'#F{$dp.$D(\'endDate\')}'*/})"/>
					&nbsp;&nbsp;&nbsp;&nbsp;
					至<input type="text" id="endDate" class="Wdate"  value="${requestScope.endDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'/*,minDate:'#F{$dp.$D(\'startDate\')}'*/})">

				</li >
				<li class="right">
					<button class='query' id="query">查询</button>
				</li>
			</ul>
			<ul class="list conditionList">
				<li class="left"><input type="checkbox" id="all">全选</li>
				<li class="right"><input id="getValue" type="button"  class="add_minus" style="width:70px;text-align:center;padding:0 0;" value="申请提现"></li>
			</ul>
			<table class="conTable" >
				<thead>
					<tr height="38px" >
						<td width="100px" align="center"><span style="margin-left:-50px;">航班号</span></td>
						<td width="249px" align="right">出发</td>
						<td width="157px" align="center">&nbsp;&nbsp;&nbsp;</td>
						<td width="202px">到达</td>
						<td width="145px" align="center">买家</td>
						<td width="88px" align="center">人数</td>
						<td width="120px" align="center">可提现金额（CNY）</td>
						<td width="115px" align="center">状态</td>
						<%--<td width="124px" align="center">操作</td>--%>
					</tr>
				</thead>
				<tbody id="tb">

				</tbody>
			</table>
        <!-- 分页 -->
        <div id="pager" class="divBox"></div>
	</div>
			
			
<script type="text/javascript" src="${ctx }/jslib/airport/fixdiv.js"></script>
<script type="text/javascript" src="${ctx }/jslib/airport/address.js"></script>
<jsp:include page="../footer.jsp"/>
</body>
</html>